package change

import (
	"jlpay-sdk-go/pkg/jlpay/models"
)

// SignInfoModifyRequest 商户签约信息修改请求
type SignInfoModifyRequest struct {
	*models.OrgBaseRequest
	ApplyID          string `json:"apply_id"`           // 申请单号
	SignMode         string `json:"sign_mode"`          // 签约方式
	AgreementPic     string `json:"agreement_pic"`      // 纸质协议照片
	LegalPersonPhone string `json:"legal_person_phone"` // 法人签约手机号码
	DelegateePhone   string `json:"delegatee_phone"`    // 授权收款人签约手机号码
}

// NewSignInfoModifyRequest 创建签约信息修改请求实例
func NewSignInfoModifyRequest() *SignInfoModifyRequest {
	return &SignInfoModifyRequest{
		OrgBaseRequest: &models.OrgBaseRequest{},
	}
}

// SetApplyID 设置申请单号
func (r *SignInfoModifyRequest) SetApplyID(applyID string) *SignInfoModifyRequest {
	r.ApplyID = applyID
	return r
}

// SetSignMode 设置签约方式
func (r *SignInfoModifyRequest) SetSignMode(signMode string) *SignInfoModifyRequest {
	r.SignMode = signMode
	return r
}

// SetAgreementPic 设置纸质协议照片
func (r *SignInfoModifyRequest) SetAgreementPic(agreementPic string) *SignInfoModifyRequest {
	r.AgreementPic = agreementPic
	return r
}

// SetLegalPersonPhone 设置法人签约手机号码
func (r *SignInfoModifyRequest) SetLegalPersonPhone(legalPersonPhone string) *SignInfoModifyRequest {
	r.LegalPersonPhone = legalPersonPhone
	return r
}

// SetDelegateePhone 设置授权收款人签约手机号码
func (r *SignInfoModifyRequest) SetDelegateePhone(delegateePhone string) *SignInfoModifyRequest {
	r.DelegateePhone = delegateePhone
	return r
}

// ToMap 将请求对象转换为字典
func (r *SignInfoModifyRequest) ToMap() (map[string]interface{}, error) {
	data, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	data["apply_id"] = r.ApplyID
	data["sign_mode"] = r.SignMode
	data["agreement_pic"] = r.AgreementPic
	data["legal_person_phone"] = r.LegalPersonPhone
	data["delegatee_phone"] = r.DelegateePhone

	return data, nil
}

// SignInfoModifyResponse 商户签约信息修改响应参数
type SignInfoModifyResponse struct {
	*models.StandardResponse
	MerchNo string `json:"merch_no"` // 商户号
	ApplyID string `json:"apply_id"` // 业务申请编号
}

// NewSignInfoModifyResponse 创建签约信息修改响应实例
func NewSignInfoModifyResponse() *SignInfoModifyResponse {
	return &SignInfoModifyResponse{
		StandardResponse: &models.StandardResponse{},
	}
}

// ToMap 将响应对象转换为字典
func (r *SignInfoModifyResponse) ToMap() (map[string]interface{}, error) {
	data := make(map[string]interface{})

	// 添加基础响应字段
	if r.RetCode != "" {
		data["ret_code"] = r.RetCode
	}
	if r.RetMsg != "" {
		data["ret_msg"] = r.RetMsg
	}

	// 添加业务字段
	if r.MerchNo != "" {
		data["merch_no"] = r.MerchNo
	}
	if r.ApplyID != "" {
		data["apply_id"] = r.ApplyID
	}

	return data, nil
}
